package com.itheima.controller;

import com.itheima.dto.ArticleConfigDto;
import com.itheima.service.ArticleService;
import com.itheima.dto.ArticleDto;
import com.itheima.dto.ArticleSaveDto;
import com.itheima.vo.ArticleConfigVo;
import com.itheima.vo.ArticleVo;
import com.itheima.vo.Result;
//import com.itheima.article.utils.MinIoTemplate;
import com.itheima.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :wujunjie
 * createTime :2022-12-28 19:12
 * description :
 */
@RestController
@RequestMapping("/api/v1/article")
@Slf4j
public class ArticleController {

    @Autowired
    private ArticleService articleService;


    @PostMapping("/load")
    public ResultVo load(@RequestBody ArticleDto articleDto){
        List<ArticleVo> articleVo=articleService.load("load",articleDto);
        return ResultVo.success(articleVo);
    }

    @PostMapping("/loadnew")
    public Result loadnew(@RequestBody ArticleDto articleDto){
        List<ArticleVo> articleVo=articleService.load("loadnew",articleDto);
        return Result.success(articleVo);
    }

    @PostMapping("/loadmore")
    public Result loadmore(@RequestBody ArticleDto articleDto){

        List<ArticleVo> articleVo=articleService.load("loadmore",articleDto);
        return Result.success(articleVo);
    }

    @PostMapping("/save")
    public Result save(@RequestBody ArticleSaveDto articleSaveDto){
        Long articleId=articleService.save(articleSaveDto);
        return Result.success(articleId);
    }

    @PostMapping("/load_article_behavior")
    public Result selectConfig(@RequestBody ArticleConfigDto articleConfigDto){
        ArticleConfigVo articleId=articleService.selectConfig(articleConfigDto);
        return Result.success(articleId);
    }



}
